package com.yuhs.zixing.study.thread;

/**
 * @description  写错了
 * @author: yuhs
 * @date 2022/3/14 下午7:16
 */
public class DCLDemo {
    private DCLDemo() {
    }

    private DCLDemo instance = null;

    public DCLDemo getInstance() {
        if (instance == null) {
            synchronized (this) {
                if (instance == null) {
                    instance = new DCLDemo();
                }
            }
        }
        return instance;
    }

    public static void main(String[] args) {
        DCLDemo dclDemo = new DCLDemo();
        for (int i = 0; i < 4; i++) {
            new Thread(() -> System.out.println(dclDemo.getInstance())).start();
        }
    }
}
